package com.tarena.lbs.attach.dao.repository.impl;


import com.tarena.lbs.attach.dao.mapper.AttachMapper;
import com.tarena.lbs.attach.dao.repository.AttachRepository;
import com.tarena.lbs.attach.pojo.param.AttachUpdateParam;
import com.tarena.lbs.attach.pojo.param.PicUpdateParam;
import com.tarena.lbs.attach.pojo.po.AttachPO;
import com.tarena.lbs.attach.pojo.query.AttachQuery;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;


@Slf4j
@Repository
public class AttachRepositoryImpl implements AttachRepository {

    @Autowired
    private AttachMapper attachMapper;

    @Override
    public boolean batchUpdateBusiness(List<PicUpdateParam> params) {
        log.info("绑定图片 执行sql之前:{}",params);
        int rows=attachMapper.batchUpdateAttachByIdOrFileUUID(params);
        log.info("绑定图片 执行sql之后:{}",rows);
        return rows>0;
    }

    @Override
    public void insert(AttachPO attachPO) {
        attachMapper.insert(attachPO);
    }

    @Override
    public List<AttachPO> getAttachInfo(AttachQuery attachQuery) {
        return attachMapper.getAttachInfo(attachQuery);
    }

    @Override
    public int deleteAttachByBusinessIdAndBusinessType(AttachUpdateParam attachUpdateParam) {
        return attachMapper.deleteAttachByBusinessIdAndBusinessType(attachUpdateParam);
    }

    @Override
    public int deleteAttachById(Long id) {
        return attachMapper.deleteAttachById(id);
    }

    @Override
    public int deleteAttachInfoByParam(AttachQuery attachQuery) {
        return attachMapper.deleteAttachInfoByParam(attachQuery);
    }

    @Override
    public List<AttachPO> batchGetAttachInfo(List<Integer> idList, Integer type) {
        return attachMapper.batchGetAttachInfo(idList,type);
    }
}
